<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport"
    content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Promise-catch</title>
  <script src="promise.js"></script>
</head>

<body>

  <script>
    /*
      promise异常传透?
        (1)	当使用promise的then链式调用时, 可以在最后指定失败的回调,
        (2)	前面任何操作出了异常, 都会传到最后失败的回调中处理
     */
    let p = new Promise((resolve, reject) => {
      // reject("ERROR");
      resolve('OK');
    });

    p
    .then()
    .then(value=>{
      console.log(value);
    })
    .then(value=>{
      console.log(value);
    })
    .catch(reason => {
      console.error(reason);
    });
  </script>

</body>

</html>